package com.EJ.ejcompanyweb.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.EJ.ejcompanyweb.HttpURLC.JsoupFragmentData;
import com.EJ.ejcompanyweb.Util.RxBus;
import com.EJ.ejcompanyweb.adapter.MyAdapter;
import com.EJ.ejcompanyweb.entity.ItemEntity;
import java.util.ArrayList;

import io.reactivex.functions.Consumer;

public class Myfragment extends Fragment {
    private  RecyclerView mRecycleView;
    private ArrayList<ItemEntity> mList=new ArrayList<ItemEntity>();
    private String mType;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (mRecycleView==null){
            mRecycleView=new RecyclerView(getActivity());
            mRecycleView.setLayoutManager(new LinearLayoutManager(getActivity()));

            String url=getArguments().getString("url");
             mType=getArguments().getString("type");

            if (url!=null){
              initRecycleView(url);
            }
          //  registerRxBus();
        }
        return mRecycleView;
    }

    private void initRecycleView(String url) {
        new JsoupFragmentData(mRecycleView).execute(url);
    }

    private void registerRxBus() {
       // RxBus.getInstance().toObservable().subscribe()
        RxBus.getInstance().toObservable().subscribe(new Consumer<Object>() {

            @Override
            public void accept(Object o) throws Exception {

           }
        });
    }
}
